package lab03.test14;


import java.sql.*;

public class Test {
    public static void main(String[] args) {

        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;

        String data = "insert into t_userinfo (usercode,username,password,email)" +
                "select '7101','宋晓梅','123456','xiaomei@yahoo.com.cn' UNION " +
                "select '7102','关松杰','654321','songjie@263.net' UNION " +
                "select '7103','李晓梅','123654','xiaomei@yahoo.com.cn' UNION " +
                "select '7104','张松岩','456123','songyan@yahoo.com.cn' UNION " +
                "select '7105','王亚杰','321456','yajie@hotmail.com' UNION " +
                "select '7106','曲小声','654321','xiaosheng@263.net' " ;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root",
                    "123456"
            );
            statement = connection.createStatement();
            statement.execute(data);
            resultSet = statement.executeQuery("SELECT * FROM t_userinfo");
            while (resultSet.next()) {
                System.out.print(resultSet.getInt(1) + "\t");
                System.out.print(resultSet.getString(2) + "\t");
                System.out.print(resultSet.getString(3) + "\t");
                System.out.print(resultSet.getString(4) + "\t");
                System.out.println();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}


